package com.yingli.animation;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    private ImageView ivAnim;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //帧动画
//        AnimationDrawable drawable;
        ivAnim = findViewById(R.id.iv_anim);
        ivAnim.setImageResource(R.drawable.transition_start);
//        drawable = (AnimationDrawable) ivAnim.getDrawable();
//        drawable.start();
        TransitionDrawable transitionDrawable = (TransitionDrawable) ivAnim.getDrawable();
        transitionDrawable.startTransition(500);
    }
}